class HttpError(Exception):
    messages = {
        204: 'No content',
        400: 'Bad request',
        401: 'Unauthorized',
        403: 'Forbidden',
        404: 'Not found',
        405: 'Method not allowed',
        411: 'Length required',
        415: 'Unsupported media type',
        500: 'Internal Server Error'
        }

    def __init__(self, code, message=None, content=None, content_type='text/plain'):
        self.code = code
        self.msg = message if message is not None else \
            (HttpError.messages[code] if code in HttpError.messages else str(code))
        self.content = content
        self.content_type = content_type

